﻿YUI.add('pregunta-opcion-view', function (Y) {
    'use strict';
    Y.PreguntaOpcionView = Y.Base.create('PreguntaOpcionView', Y.View, [], {
        templateIsCharged: false,
        loadTemplate: function () {
            if (this.template == '') {
                var that = this,
                validator = null,
                request = Y.io('/ExcellentProject/scripts/views/cuestionarios/preguntasopciones/templates/preguntaopcion.html', {
                    on: {
                        complete: function (id, response) {
                            that.templateIsCharged = true;
                            that.template = response.responseText;
                            that.render();
                        }
                    },
                    failure: function (id, response) {
                        alert(response)
                    }
                })
            }
        },
        render: function () {
            debugger
            this.loadTemplate();
            if (this.templateIsCharged) {
                var contentTemplate = Y.Handlebars.compile(this.template);
                this.get('container').setHTML(contentTemplate(Y.merge(this.get('model')[0])));
                var statusList = document.getElementById('estado');
                //if (this.get('model').get('IdPregunta') != 0) {
                //    var statusListSelected = Y.one('#estado');
                //    statusListSelected.set('value', this.get('model').get('Estado'));
                //}
            }
        }, 
    })
}, '1.0.0.0', { requires: ['handlebars',  'node',  'event', 'node-event-simulate', 'pregunta-model-list','pregunta-model'] })